﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.RobotJog.CApRJRobotJogUtilities
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media.Imaging;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.RobotJog;

internal static class CApRJRobotJogUtilities
{
  internal static string LOCATION_EXPANDER_EXPANDED = "LocationExpanderExpanded";
  internal static string MANIPULATION_EXPANDER_EXPANDED = "ManipulationExpanderExpaded";
  internal static string EXTERNAL_JOINTS_EXPANDER_EXPANDED = "ExternalJointsExpanderExpanded";
  internal static string ALL_JOINTS_EXPANDER_EXPANDED = "AllJointsExpanderExpanded";
  internal static string COORDINATE_REFERENCE_EXPANDER_EXPANDED = "CoordinateReferenceExpanderExpanded";
  internal static string LOCK_TCPF_CHECKED = "LockTCPF";
  internal static string ENABLE_ROBOT_PLACEMENT_CHECKED = "EnableRobotPlacement";
  internal static string ENABLE_ROBOT_ATTACHMENTS_PLACEMENT_SELECTED = "EnableRobotAttachmentsPlacement";
  internal static string SET_EXTERNAL_VALUES_CHECKED = "SetExternalValues";
  internal static string LOCK_CONFIGURATION_CHECKED = "LockConfiguration";
  internal static string SNAP_BY_STEP_SIZE_CHECKED = "SnapByStepSize";
  internal static string SHOW_DEPENDENT_JOINTS_CHECKED = "ShowDependentJoints";
  internal static string ENABLE_WELD_POINT_LOCATION_MANIPULATION = "Enable Weld Point Location Manipulation";
  internal static string IGNORE_WELD_LOCATION_LIMITATIONS = "Ignore Weld Location Limitations";
  internal static string ENABLE_SEAM_LOCATION_MANIPULATION = "Enable Continuous Location Manipulation";
  internal static string IGNORE_SEAM_LOCATION_LIMITATIONS = "Ignore Continuous Location Limitations";
  internal static string FRAME_OF_REFERENCE = "FrameOfReference";
  public static string COORDINATE_REFERENCE_LOCATION_RELATIVE = "CoordinateReferenceLocationRelative";
  public static string COPY_PARAMETERS = "CopyParameters";
  private static ITxTypeFilter _locatableObjsFilter = (ITxTypeFilter) new TxTypeFilter(typeof (ITxLocatableObject));
  private static bool _isWeldLocationManipulationEnabled = CApRJRobotJogUtilities.LoadRegistryEnableWeldLocationManipulation();
  private static bool _IgnoreWeldOperationLocationLimitations = CApRJRobotJogUtilities.LoadRegistryIgnoreWeldLocationLimitations();
  private static bool _isSeamLocationManipulationEnabled = CApRJRobotJogUtilities.LoadRegistryEnablSeamLocationManipulation();
  private static bool _IgnoreSeamOperationLocationLimitations = CApRJRobotJogUtilities.LoadRegistryIgnoreSeamLocationLimitations();

  internal static void StoreControlsStates(TxWindow wnd, Dictionary<string, bool> contorolsState)
  {
    foreach (KeyValuePair<string, bool> keyValuePair in contorolsState)
      CApRJRobotJogUtilities.SetBoolValueToRegistry(wnd, keyValuePair.Key, keyValuePair.Value);
  }

  internal static Dictionary<string, bool> LoadControlsStates(TxWindow wnd)
  {
    return new Dictionary<string, bool>()
    {
      {
        CApRJRobotJogUtilities.LOCATION_EXPANDER_EXPANDED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.LOCATION_EXPANDER_EXPANDED, true)
      },
      {
        CApRJRobotJogUtilities.MANIPULATION_EXPANDER_EXPANDED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.MANIPULATION_EXPANDER_EXPANDED, true)
      },
      {
        CApRJRobotJogUtilities.EXTERNAL_JOINTS_EXPANDER_EXPANDED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.EXTERNAL_JOINTS_EXPANDER_EXPANDED, false)
      },
      {
        CApRJRobotJogUtilities.ALL_JOINTS_EXPANDER_EXPANDED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.ALL_JOINTS_EXPANDER_EXPANDED, false)
      },
      {
        CApRJRobotJogUtilities.COORDINATE_REFERENCE_EXPANDER_EXPANDED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.COORDINATE_REFERENCE_EXPANDER_EXPANDED, false)
      },
      {
        CApRJRobotJogUtilities.LOCK_TCPF_CHECKED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.LOCK_TCPF_CHECKED, false)
      },
      {
        CApRJRobotJogUtilities.ENABLE_ROBOT_PLACEMENT_CHECKED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.ENABLE_ROBOT_PLACEMENT_CHECKED, false)
      },
      {
        CApRJRobotJogUtilities.ENABLE_ROBOT_ATTACHMENTS_PLACEMENT_SELECTED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.ENABLE_ROBOT_ATTACHMENTS_PLACEMENT_SELECTED, false)
      },
      {
        CApRJRobotJogUtilities.LOCK_CONFIGURATION_CHECKED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.LOCK_CONFIGURATION_CHECKED, false)
      },
      {
        CApRJRobotJogUtilities.SNAP_BY_STEP_SIZE_CHECKED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.SNAP_BY_STEP_SIZE_CHECKED, true)
      },
      {
        CApRJRobotJogUtilities.SHOW_DEPENDENT_JOINTS_CHECKED,
        CApRJRobotJogUtilities.GetBoolValueFromRegistry(wnd, CApRJRobotJogUtilities.SHOW_DEPENDENT_JOINTS_CHECKED, false)
      }
    };
  }

  private static bool GetBoolValueFromRegistry(TxWindow wnd, string valueName, bool defaultValue)
  {
    bool result = defaultValue;
    object obj = (object) null;
    TxWindowSettings.RestoreWindowValue(wnd, valueName, ref obj);
    if (obj != null)
      bool.TryParse(obj as string, out result);
    return result;
  }

  private static void SetBoolValueToRegistry(TxWindow wnd, string valueName, bool theValue)
  {
    TxWindowSettings.StoreWindowValue(wnd, valueName, (object) theValue);
  }

  public static int GetIntValueFromRegistry(TxWindow wnd, string key, int defaultValue)
  {
    int valueFromRegistry = defaultValue;
    object obj = (object) null;
    TxWindowSettings.RestoreWindowValue(wnd, key, ref obj);
    if (obj != null)
      valueFromRegistry = (int) obj;
    return valueFromRegistry;
  }

  public static void SetIntValueToRegistry(TxWindow wnd, string key, int value)
  {
    TxWindowSettings.StoreWindowValue(wnd, key, (object) value);
  }

  public static string GetStringValueFromRegistry(TxWindow wnd, string key, string defaultValue)
  {
    string valueFromRegistry = defaultValue;
    object obj = (object) null;
    TxWindowSettings.RestoreWindowValue(wnd, key, ref obj);
    if (obj != null)
      valueFromRegistry = obj.ToString();
    return valueFromRegistry;
  }

  public static void SetStringValueToRegistry(TxWindow wnd, string key, string value)
  {
    TxWindowSettings.StoreWindowValue(wnd, key, (object) value);
  }

  public static BitmapSource GetIcon(Image image)
  {
    if (image == null)
      return (BitmapSource) null;
    IntPtr hbitmap = new Bitmap(image).GetHbitmap();
    BitmapSource sourceFromHbitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
    sourceFromHbitmap.Freeze();
    CApRJRobotJogUtilities.DeleteObject(hbitmap);
    return sourceFromHbitmap;
  }

  [DllImport("gdi32.dll")]
  [return: MarshalAs(UnmanagedType.Bool)]
  internal static extern bool DeleteObject(IntPtr value);

  public static void CopyParametersAndOLP(
    ITxRoboticLocationOperation source,
    ITxRoboticLocationOperation target)
  {
    CApRJRobotJogUtilities.CopyParameters(source, target);
    CApRJRobotJogUtilities.CopyOLPCommands(source, target);
  }

  public static void CopyParametersOnly(
    ITxRoboticLocationOperation source,
    ITxRoboticLocationOperation target)
  {
    CApRJRobotJogUtilities.CopyParameters(source, target);
  }

  private static void CopyParameters(
    ITxRoboticLocationOperation source,
    ITxRoboticLocationOperation target)
  {
    if (((ITxRoboticOperation) target).Parameters != null)
    {
      foreach (TxRoboticParam parameter in ((ITxRoboticOperation) target).Parameters)
      {
        if (source != null)
          ((ITxRoboticOperation) target).RemoveParameter(parameter.Type);
      }
    }
    foreach (TxRoboticParam parameter in ((ITxRoboticOperation) source).Parameters)
      ((ITxRoboticOperation) target).SetParameter(parameter);
    ((ITxRoboticOperation) target).RemoveParameter("POSITION_IN_SIMULATION");
  }

  private static void CopyOLPCommands(
    ITxRoboticLocationOperation source,
    ITxRoboticLocationOperation target)
  {
    if (source == null)
      return;
    if (((ITxRoboticOperation) target).Commands != null)
    {
      foreach (ITxObject command in (Collection<ITxObject>) ((ITxRoboticOperation) target).Commands)
        command.Delete();
    }
    if (((ITxRoboticOperation) source).Commands == null)
      return;
    foreach (ITxObject command1 in (Collection<ITxObject>) ((ITxRoboticOperation) source).Commands)
    {
      if (command1 is TxRoboticCompositeCommand)
      {
        TxRoboticCompositeCommand compositeCommand1 = command1 as TxRoboticCompositeCommand;
        TxRoboticCompositeCommandCreationData commandCreationData = new TxRoboticCompositeCommandCreationData(compositeCommand1.Elements);
        ((TxObjectCreationData) commandCreationData).Name = ((TxRoboticCommand) compositeCommand1).Name;
        TxRoboticCompositeCommand compositeCommand2 = ((ITxRoboticOperation) target).CreateCompositeCommand(commandCreationData);
        if (command1.Attributes != null)
        {
          foreach (TxAttribute attribute in command1.Attributes)
            ((TxRoboticCommand) compositeCommand2).SetAttribute(attribute);
        }
        ((TxRoboticCommand) compositeCommand2).Text = ((TxRoboticCommand) (command1 as TxRoboticCompositeCommand)).Text;
      }
      else if (command1 is TxRoboticCommand)
      {
        TxRoboticCommand txRoboticCommand = command1 as TxRoboticCommand;
        TxRoboticCommandCreationData commandCreationData = new TxRoboticCommandCreationData(txRoboticCommand.Text);
        ((TxObjectCreationData) commandCreationData).Name = txRoboticCommand.Name;
        TxRoboticCommand command2 = ((ITxRoboticOperation) target).CreateCommand(commandCreationData);
        if (command1.Attributes != null)
        {
          foreach (TxAttribute attribute in command1.Attributes)
            command2.SetAttribute(attribute);
        }
      }
    }
  }

  public static void AttachTargetToSourceAttachment(
    ITxRoboticLocationOperation source,
    ITxRoboticLocationOperation target)
  {
    ITxLocatableObject itxLocatableObject1 = source as ITxLocatableObject;
    ITxLocatableObject itxLocatableObject2 = target as ITxLocatableObject;
    if (itxLocatableObject1 == null || itxLocatableObject2 == null || itxLocatableObject1.AttachmentType != null || !itxLocatableObject2.CanAttachTo(itxLocatableObject1))
      return;
    itxLocatableObject2.AttachTo(itxLocatableObject1.AttachmentParent);
  }

  public static void DetachRoboticLocationOperation(ITxRoboticLocationOperation target)
  {
    if (!(target is ITxLocatableObject itxLocatableObject))
      return;
    itxLocatableObject.Detach();
  }

  private static void StoreOptionsWeldRegistryValue(string valueName, bool enable)
  {
    CApRJRobotJogUtilities.GetOptionsWeldRegistryKey(Registry.CurrentUser, true)?.SetValue(valueName, (object) enable, RegistryValueKind.DWord);
  }

  private static void StoreOptionsSeamRegistryValue(string valueName, bool enable)
  {
    CApRJRobotJogUtilities.GetOptionsSeamRegistryKey(Registry.CurrentUser, true)?.SetValue(valueName, (object) enable, RegistryValueKind.DWord);
  }

  private static bool GetBoolValueFromRegistryKey(RegistryKey entryKey, string valueName)
  {
    if (entryKey == null)
      return false;
    object obj = entryKey.GetValue(valueName);
    return obj != null && obj is int num && num == 1;
  }

  private static bool LoadRegistryEnableWeldLocationManipulation()
  {
    return CApRJRobotJogUtilities.GetBoolValueFromRegistryKey(CApRJRobotJogUtilities.GetOptionsWeldRegistryKey(Registry.CurrentUser) ?? CApRJRobotJogUtilities.GetOptionsWeldRegistryKey(Registry.LocalMachine), CApRJRobotJogUtilities.ENABLE_WELD_POINT_LOCATION_MANIPULATION);
  }

  private static bool LoadRegistryIgnoreWeldLocationLimitations()
  {
    return CApRJRobotJogUtilities.GetBoolValueFromRegistryKey(CApRJRobotJogUtilities.GetOptionsWeldRegistryKey(Registry.CurrentUser), CApRJRobotJogUtilities.IGNORE_WELD_LOCATION_LIMITATIONS);
  }

  private static string GetWeldOptionsSubKeyPath()
  {
    return TxApplicationEx.ConfigurationPath + "\\Options\\Weld";
  }

  private static RegistryKey GetOptionsWeldRegistryKey(RegistryKey rootKey, bool openForWriting = false)
  {
    RegistryKey optionsWeldRegistryKey = rootKey.OpenSubKey(CApRJRobotJogUtilities.GetWeldOptionsSubKeyPath(), openForWriting);
    if (!openForWriting || optionsWeldRegistryKey != null)
      return optionsWeldRegistryKey;
    rootKey.CreateSubKey(CApRJRobotJogUtilities.GetWeldOptionsSubKeyPath());
    return rootKey.OpenSubKey(CApRJRobotJogUtilities.GetWeldOptionsSubKeyPath(), openForWriting);
  }

  private static bool LoadRegistryEnablSeamLocationManipulation()
  {
    return CApRJRobotJogUtilities.GetBoolValueFromRegistryKey(CApRJRobotJogUtilities.GetOptionsSeamRegistryKey(Registry.CurrentUser) ?? CApRJRobotJogUtilities.GetOptionsSeamRegistryKey(Registry.LocalMachine), CApRJRobotJogUtilities.ENABLE_SEAM_LOCATION_MANIPULATION);
  }

  private static bool LoadRegistryIgnoreSeamLocationLimitations()
  {
    return CApRJRobotJogUtilities.GetBoolValueFromRegistryKey(CApRJRobotJogUtilities.GetOptionsSeamRegistryKey(Registry.CurrentUser), CApRJRobotJogUtilities.IGNORE_SEAM_LOCATION_LIMITATIONS);
  }

  private static string GetSeamOptionsSubKeyPath()
  {
    return TxApplicationEx.ConfigurationPath + "\\Options\\Continuous";
  }

  private static RegistryKey GetOptionsSeamRegistryKey(RegistryKey rootKey, bool openForWriting = false)
  {
    RegistryKey optionsSeamRegistryKey = rootKey.OpenSubKey(CApRJRobotJogUtilities.GetSeamOptionsSubKeyPath(), openForWriting);
    if (!openForWriting || optionsSeamRegistryKey != null)
      return optionsSeamRegistryKey;
    rootKey.CreateSubKey(CApRJRobotJogUtilities.GetSeamOptionsSubKeyPath());
    return rootKey.OpenSubKey(CApRJRobotJogUtilities.GetSeamOptionsSubKeyPath(), openForWriting);
  }

  internal static bool IsOpenable(ITxObject selectedObject)
  {
    return selectedObject is ITxRobot || CApRJRobotJogUtilities.IsRoboticLocationOperationWithAssignedRobot(selectedObject) || CApRJRobotJogUtilities.IsCompoundEquipment(selectedObject);
  }

  internal static bool IsCompoundEquipment(ITxObject selectedObject)
  {
    switch (selectedObject)
    {
      case ITxComponent _:
        if ((selectedObject as ITxComponent).IsEquipment && selectedObject is ITxObjectCollection)
        {
          TxObjectList allDescendants = (selectedObject as ITxObjectCollection).GetAllDescendants((ITxTypeFilter) new TxTypeFilter(typeof (ITxRobot)));
          return allDescendants != null && ((Collection<ITxObject>) allDescendants).Count > 0;
        }
        break;
    }
    return false;
  }

  internal static bool IsRoboticLocationOperationWithAssignedRobot(ITxObject selectedObject)
  {
    return CApRJRobotJogUtilities.GetRoboticLocationOperationAssignedRobot(selectedObject) != null;
  }

  internal static ITxRobot GetRoboticLocationOperationAssignedRobot(ITxObject selectedObject)
  {
    return selectedObject is ITxRoboticLocationOperation locationOperation && locationOperation.ParentRoboticOperation != null ? locationOperation.ParentRoboticOperation.Robot : (ITxRobot) null;
  }

  internal static bool IsMovableLocation(ITxRoboticLocationOperation location)
  {
    switch (location)
    {
      case TxRoboticViaLocationOperation _:
      case TxGenericRoboticLocationOperation _:
      case TxRoboticSeamLocationOperation _ when CApRJRobotJogUtilities.IsSeamLocationManipulationEnabled:
        return true;
      case TxWeldLocationOperation _ when CApRJRobotJogUtilities.IsWeldLocationManipulationEnabled:
        return (location as TxWeldLocationOperation).IsProjected;
      default:
        return false;
    }
  }

  internal static bool AreLocationLimitationsIgnored(ITxRoboticLocationOperation location)
  {
    return location == null || location is TxRoboticViaLocationOperation || location is TxGenericRoboticLocationOperation || location is TxRoboticSeamLocationOperation && CApRJRobotJogUtilities.IgnoreSeamOperationLocationLimitations || location is TxWeldLocationOperation && CApRJRobotJogUtilities.IgnoreWeldOperationLocationLimitations;
  }

  internal static bool IsLocationMovementValid(ITxRoboticLocationOperation location)
  {
    return location == null || CApRJRobotJogUtilities.AreLocationLimitationsIgnored(location) || new TxLocationManipulationEx((ITxObject) location).GetLocationStatus((LocationStatusCheck) 0) != 1;
  }

  internal static List<ITxLocatableObject> GetAttachmentChain(ITxLocatableObject robot)
  {
    List<ITxLocatableObject> chain = new List<ITxLocatableObject>();
    CApRJRobotJogUtilities.GetParentAttachment(robot, ref chain);
    return chain;
  }

  internal static TxObjectList GetAttachmentObjects(ITxLocatableObject obj)
  {
    TxObjectList attachmentObjects = new TxObjectList();
    if (obj != null)
    {
      CApRJRobotJogUtilities.GetObjectAttachmentDescendants(obj, attachmentObjects);
      CApRJRobotJogUtilities.GetObjectTwoWayAttachedAncestors(obj, attachmentObjects);
    }
    return attachmentObjects;
  }

  internal static void GetObjectAttachmentDescendants(
    ITxLocatableObject obj,
    TxObjectList descendants)
  {
    foreach (ITxObject attachmentDescendant in (Collection<ITxObject>) TxLocatableObjectEx.GetAllDirectAttachmentDescendants(obj, CApRJRobotJogUtilities._locatableObjsFilter))
    {
      ((Collection<ITxObject>) descendants).Add(attachmentDescendant);
      CApRJRobotJogUtilities.GetObjectAttachmentDescendants(attachmentDescendant as ITxLocatableObject, descendants);
    }
  }

  internal static void GetObjectTwoWayAttachedAncestors(
    ITxLocatableObject obj,
    TxObjectList ancestors)
  {
    ITxLocatableObject attachmentParent = obj.AttachmentParent;
    if (attachmentParent == null || obj.AttachmentType != 1)
      return;
    ((Collection<ITxObject>) ancestors).Add((ITxObject) attachmentParent);
    CApRJRobotJogUtilities.GetObjectTwoWayAttachedAncestors(attachmentParent, ancestors);
  }

  internal static void GetParentAttachment(
    ITxLocatableObject obj,
    ref List<ITxLocatableObject> chain)
  {
    if (obj == null || obj.AttachmentParent == null)
      return;
    ITxLocatableObject itxLocatableObject = obj.AttachmentParent;
    if ((itxLocatableObject is TxFrame || itxLocatableObject is TxKinematicLink) && TxEngineeringDataInternal.GetScope((ITxObject) itxLocatableObject) is ITxLocatableObject scope)
      itxLocatableObject = scope;
    if (itxLocatableObject == null || !(((ITxObject) itxLocatableObject).GetType() != typeof (TxPhysicalRoot)))
      return;
    if (TxObjectEx.GetLowestLevelNonModelObject((ITxObject) itxLocatableObject) is ITxComponent levelNonModelObject && levelNonModelObject.IsEquipment)
      chain.Add(levelNonModelObject as ITxLocatableObject);
    else
      chain.Add(itxLocatableObject);
    CApRJRobotJogUtilities.GetParentAttachment(itxLocatableObject, ref chain);
  }

  internal static ITxLocatableObject GetTopMostRobotAttachment(
    List<ITxLocatableObject> attachmentChain)
  {
    ITxLocatableObject mostRobotAttachment = (ITxLocatableObject) null;
    if (attachmentChain != null && attachmentChain.Count > 0)
      mostRobotAttachment = attachmentChain[attachmentChain.Count - 1];
    return mostRobotAttachment;
  }

  internal static bool IsWeldLocationManipulationEnabled
  {
    get => CApRJRobotJogUtilities._isWeldLocationManipulationEnabled;
    set
    {
      if (value == CApRJRobotJogUtilities._isWeldLocationManipulationEnabled)
        return;
      CApRJRobotJogUtilities._isWeldLocationManipulationEnabled = value;
      CApRJRobotJogUtilities.StoreOptionsWeldRegistryValue(CApRJRobotJogUtilities.ENABLE_WELD_POINT_LOCATION_MANIPULATION, value);
    }
  }

  internal static bool IgnoreWeldOperationLocationLimitations
  {
    get => CApRJRobotJogUtilities._IgnoreWeldOperationLocationLimitations;
    set
    {
      if (value == CApRJRobotJogUtilities._IgnoreWeldOperationLocationLimitations)
        return;
      CApRJRobotJogUtilities._IgnoreWeldOperationLocationLimitations = value;
      CApRJRobotJogUtilities.StoreOptionsWeldRegistryValue(CApRJRobotJogUtilities.IGNORE_WELD_LOCATION_LIMITATIONS, value);
    }
  }

  internal static bool IsSeamLocationManipulationEnabled
  {
    get => CApRJRobotJogUtilities._isSeamLocationManipulationEnabled;
    set
    {
      if (value == CApRJRobotJogUtilities._isSeamLocationManipulationEnabled)
        return;
      CApRJRobotJogUtilities._isSeamLocationManipulationEnabled = value;
      CApRJRobotJogUtilities.StoreOptionsSeamRegistryValue(CApRJRobotJogUtilities.ENABLE_SEAM_LOCATION_MANIPULATION, value);
    }
  }

  internal static bool IgnoreSeamOperationLocationLimitations
  {
    get => CApRJRobotJogUtilities._IgnoreSeamOperationLocationLimitations;
    set
    {
      if (value == CApRJRobotJogUtilities._IgnoreSeamOperationLocationLimitations)
        return;
      CApRJRobotJogUtilities._IgnoreSeamOperationLocationLimitations = value;
      CApRJRobotJogUtilities.StoreOptionsSeamRegistryValue(CApRJRobotJogUtilities.IGNORE_SEAM_LOCATION_LIMITATIONS, value);
    }
  }

  public static void SetLocationAsActiveSelection(ITxLocationOperation location)
  {
    TxObjectList txObjectList = new TxObjectList();
    ((Collection<ITxObject>) txObjectList).Add((ITxObject) location);
    TxApplication.ActiveSelection.SetItems(txObjectList);
  }

  internal static TxPlacementManipulatorElement GetManipulatorElementByAxis(Axes axes)
  {
    TxPlacementManipulatorElement manipulatorElementByAxis = (TxPlacementManipulatorElement) 0;
    switch (axes - 1)
    {
      case 0:
        manipulatorElementByAxis = (TxPlacementManipulatorElement) 1;
        break;
      case 1:
        manipulatorElementByAxis = (TxPlacementManipulatorElement) 4;
        break;
      case 2:
        manipulatorElementByAxis = (TxPlacementManipulatorElement) 7;
        break;
      case 3:
        manipulatorElementByAxis = (TxPlacementManipulatorElement) 2;
        break;
      case 4:
        manipulatorElementByAxis = (TxPlacementManipulatorElement) 5;
        break;
      case 5:
        manipulatorElementByAxis = (TxPlacementManipulatorElement) 8;
        break;
    }
    return manipulatorElementByAxis;
  }

  internal static Axes GetAxisByManipulatorElement(TxPlacementManipulatorElement element)
  {
    Axes manipulatorElement = (Axes) 0;
    switch (element - 1)
    {
      case 0:
        manipulatorElement = (Axes) 1;
        break;
      case 1:
        manipulatorElement = (Axes) 4;
        break;
      case 3:
        manipulatorElement = (Axes) 2;
        break;
      case 4:
        manipulatorElement = (Axes) 5;
        break;
      case 6:
        manipulatorElement = (Axes) 3;
        break;
      case 7:
        manipulatorElement = (Axes) 6;
        break;
    }
    return manipulatorElement;
  }
}
